let strtest:string="LI"; 
console.log(romanToInt(strtest));''
function romanToInt(s: string): number {
  let result:number=0;
  let arr: [string,number][] = [
    ['I',1],
    ['V',5],
    ['X',10],
    ['L',50],
    ['C',100],
    ['D',500],
    ['M',1000],
  ];
  let map = new Map<string, number>(arr)
  for(let i=0;i<s.length;i++){
    if(i===s.length-1)//确保下面的至少是倒数第二个
        {
            result+=map.get(s[i])!;
            break;
        }
    switch (s[i]){
        case "I":
            // if(map.get(s[i+1])!>map.get(s[i])!)
            if(s[i+1]==="V"){
                result+=4;
                i++;
            }else if(s[i+1]==="X"){
                result+=9;
                i++;
            }
            else result+=1
            break;
        case "V":
            result+=5
            break;
        case "X":
            if(s[i+1]==="L"){
                result+=40;
                i++;
            }else if(s[i+1]==="C"){
                result+=90;
                i++;
            }
            else result+=10
            break;
        case "L":
            result+=50
            break;
        case "C":
            if(s[i+1]==="D"){
                result+=400;
                i++;
            }else if(s[i+1]==="M"){
                result+=900;
                i++;
            }
            else result+=100    
            break;
        case "D":
            result+=500
            break;
        case "M":
            result+=1000
            break;
    }
  }
  return result;  
};